Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build custom code before packaging #77

Merged
merged 1 commit into from
Apr 25, 2018
Merged

Build custom code before packaging #77

merged 1 commit into from
Apr 25, 2018

Conversation

hbeachey
Copy link
Contributor

@hbeachey hbeachey commented Mar 6, 2018

We wanted to be able to run gulp create-package without worrying about which view was last run or when it was run. This PR updates the gulp commands to build the custom code before the package is created.

As a nice side-effect, this also adds the prompt for which view to use to gulp run, meaning --view is no longer necessary (but still available). It also adds the --view flag to gulp create-package so these two commands are now callable either way.

As a side note, this is my first foray into gulp tasks, and I had some difficulty getting the dependencies to wait for the view selection task, so if anyone has suggestions on a better way please speak up!

@etgrieco
Copy link
Contributor

@hbeachey @noamamit92 this change caused a regression when merging this into our fork.

For some reason, it would not properly bundle/minify the code when we would target our CENTRAL_PACKAGE. Moreover, browserify would come up with an error that the same value was being declared twice, as if a file were being for some reason read multiple times.

We cherry-picked this commit out so our fork still works, and if we have time will take a look if there is something that can be improved for greater compatibility.

Any thoughts?

etgrieco pushed a commit to NYULibraries/primo-explore-devenv that referenced this pull request Nov 30, 2018
…ightly alter view selection options (ExLibrisGroup#77)"

This reverts commit f18425b.
@gpeterso
Copy link
Contributor

@etgrieco I can't recall if the error I encountered was the same as the one you're describing, but I found that I needed to change my packaging script after this PR was merged:
before: gulp create-package
after: gulp create-package --browserify --view CENTRAL_PACKAGE

@etgrieco
Copy link
Contributor

etgrieco commented Nov 30, 2018

@gpeterso Thank you very much, I will experiment with this.
EDIT: Yep, that did the trick. I thought I had experimented with this, but I guess I missed something somewhere...thanks again!

etgrieco pushed a commit to NYULibraries/primo-explore-devenv that referenced this pull request Nov 30, 2018
…ll as slightly alter view selection options (ExLibrisGroup#77)""

This reverts commit c7d47fe.
@etgrieco
Copy link
Contributor

@hbeachey @gpeterso So the issue I'm running into at this point is using the --browserify option works, but it does not wait until the JS compilation task is complete before creating the package. For example, if I deletecustom.js before running the task, then no Javascript file appears in the package at all; however, there is indeed a newly created custom.js file in my directory.

@gpeterso
Copy link
Contributor

Ah. Yeah, I see what you mean. I can reproduce this problem. I just hadn't encountered it before because of my workflow.

@etgrieco
Copy link
Contributor

etgrieco commented Nov 30, 2018

@gpeterso Thanks for looking into it so promptly! I'll create an issue. This definitely is a problem since it will not bring over changes between packagings if you don't run the server; the current PR was intended to fix that issue.

da70 added a commit to NYULibraries/primo-explore-devenv that referenced this pull request May 8, 2023
….2` to succeed [+]

Added packages mentioned in [this comment](node-gfx/node-canvas-prebuilt#77 (comment)) of [linux\-musl build \ExLibrisGroup#77](node-gfx/node-canvas-prebuilt#77) to fix this problem in `docker compose` `web` build:

```shell
Command: node-pre-gyp install --fallback-to-build --update-binary
Arguments:
Directory: /tmp/node_modules/canvas
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@1.0.10
node-pre-gyp info using node@16.17.0 | linux | x64
node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v93-linux-musl-x64.tar.gz
node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v93-linux-musl-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@16.17.0 (node-v93 ABI, musl) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v93-linux-musl-x64.tar.gz
gyp info it worked if it ends with ok
gyp info using node-gyp@9.0.0
gyp info using node@16.17.0 | linux | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.0.0
gyp info using node@16.17.0 | linux | x64
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16)
gyp ERR! stack     at exithandler (node:child_process:408:5)
gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:420:5)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
gyp ERR! stack     at onErrorNT (node:internal/child_process:478:16)
gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
gyp ERR! System Linux 5.4.0-1025-aws
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--update-binary" "--module=/tmp/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/tmp/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
gyp ERR! cwd /tmp/node_modules/canvas
gyp ERR! node -v v16.17.0
gyp ERR! node-gyp -v v9.0.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/tmp/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/tmp/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/tmp/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1093:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
node-pre-gyp ERR! System Linux 5.4.0-1025-aws
node-pre-gyp ERR! command "/usr/local/bin/node" "/tmp/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
node-pre-gyp ERR! cwd /tmp/node_modules/canvas
node-pre-gyp ERR! node -v v16.17.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.10
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/tmp/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/tmp/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
ERROR: Service 'web' failed to build: The command '/bin/sh -c cd /tmp && yarn install --frozen-lockfile --ignore-optional   && mkdir -p $INSTALL_PATH   && cd $INSTALL_PATH   && cp -R /tmp/node_modules $INSTALL_PATH   && rm -r /tmp/* && yarn cache clean' returned a non-zero code: 1
```

For details, see `canvas` issue: [How to Troubleshoot Installation \#1511](Automattic/node-canvas#1511)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants